package com.zhilianbao.leyaogo.listener;

import android.view.View;

import java.util.Calendar;

/**
 * 用于控件防抖操作的监听，一分钟只能点击一次
 * Created by gyt on 2016/12/24
 */
public abstract class NoDoubleClickListener implements View.OnClickListener{

    public static final int MIN_Click_DELAY_TIME = 1000;
    public long lastClickTime;
    @Override
    public void onClick(View v) {
        long curClickTime = Calendar.getInstance().getTimeInMillis();
        if (curClickTime - lastClickTime > MIN_Click_DELAY_TIME) {
            lastClickTime = curClickTime;
            onNoDoubleClick(v);
        }
    }

    protected abstract void onNoDoubleClick(View v);
}
